package webdev.danagtravel;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import webdev.customlib.zoomphoto.adapter.FullScreenImageAdapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import dev.danang.R;

public class FullScreenViewActivity extends Activity{

//	private Utils utils;
	private FullScreenImageAdapter adapter;
	private ViewPager viewPager;
	private ArrayList<String> imagePaths = new ArrayList<String>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fullscreen_view);

		viewPager = (ViewPager) findViewById(R.id.pager);

//		utils = new Utils(getApplicationContext());

		Intent intent = getIntent();
		int position = intent.getIntExtra("position", 0);
		try {
			List<String> arr = getImage(this);
			for (int i = 0; i < arr.size(); i++) {
				imagePaths.add(arr.get(i));
			}
//			imagePaths = getImage(getActivity());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		adapter = new FullScreenImageAdapter(FullScreenViewActivity.this,
//				utils.getFilePaths());
		adapter = new FullScreenImageAdapter(FullScreenViewActivity.this, imagePaths);
		viewPager.setAdapter(adapter);

		// displaying selected image first
		viewPager.setCurrentItem(position);
	}
	private List<String> getImage(Context conetx) throws IOException
    {
      AssetManager assetManager =conetx.getAssets();
      String[] files = assetManager.list("image");   
      List<String> it =  Arrays.asList(files);
      return it; 

    }
}
